// ignore_for_file: prefer_const_constructors, curly_braces_in_flow_control_structures

import 'package:flutter_getx_1/page/my/my.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';

import '../DetailView/DetailView.dart';
import '../list/List.dart';

class NestedController extends GetxController {
static NestedController get to => Get.find();

  var currentIndex = 0.obs;

  final pages = <String>['/list', '/home/list/detail', '/detal'];

  void changePage(int index) {
    currentIndex.value = index;
    Get.toNamed(pages[index], id: 1);
  }
  Route? onGenerateRoute(RouteSettings settings){
    if (settings.name == "/list") 
      return GetPageRoute(
        settings: settings,
        page: () => ListIndexView(),
        transition: Transition.topLevel,
      );
    else if(settings.name == "/home/list/detail")
      return GetPageRoute(
        settings: settings,
        page: () => DetailView(),
        transition: Transition.rightToLeftWithFade
      );
    else if(settings.name == "/detal")
      return GetPageRoute(
        settings: settings,
        page: () => MyView(),
        transition: Transition.fadeIn
      );
    
    return null;
  }
}